package com.demo.controller;

import java.security.Principal;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class SecurityController {

	@Value("${pakho.test}")
	private String pakho;

	@RequestMapping("/hello")
	public ModelAndView hello(String name) {
		// Map<String,Object> map =new ConcurrentHashMap<>();
		ModelAndView mv = new ModelAndView();
		mv.setViewName("hello");
		mv.addObject("hi ", name);
		return mv;
	}

	// @RequestMapping("/login")
	// public ModelAndView login(String name) {
	// ModelAndView mv = new ModelAndView();
	// mv.setViewName("login");
	// return mv;
	// }

	@RequestMapping("/")
	public String home1() {
		return "redirect:/home";
	}

	@RequestMapping("/home")
	public ModelAndView home2() {
		ModelAndView mv = new ModelAndView();
		mv.addObject("pakho", pakho);
		mv.setViewName("home");
		return mv;
	}

	@RequestMapping("/user")
	@ResponseBody
	public Principal user(Principal user) {
		return user;
	}
}
